package com.ruoyi.business.controller;

import com.ruoyi.business.domain.FileInternalTransferIn;
import com.ruoyi.business.service.IFileInternalTransferInService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 内部转入Controller
 *
 * @author ruoyi
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/business/in")
public class FileInternalTransferInController extends BaseController
{
    @Autowired
    private IFileInternalTransferInService fileInternalTransferInService;

    /**
     * 查询内部转入列表
     */
    @PreAuthorize("@ss.hasPermi('business:in:list')")
    @GetMapping("/list")
    public TableDataInfo list(FileInternalTransferIn fileInternalTransferIn, PageQuery pageQuery)
    {
        return fileInternalTransferInService.selectPageFileInternalTransferInList(fileInternalTransferIn, pageQuery);
//        startPage();
//        List<FileInternalTransferIn> list = fileInternalTransferInService.selectFileInternalTransferInList(fileInternalTransferIn);
//        return getDataTable(list);
    }

    /**
     * 导出内部转入列表
     */
    @PreAuthorize("@ss.hasPermi('business:in:export')")
    @Log(title = "内部转入", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(FileInternalTransferIn fileInternalTransferIn, HttpServletResponse response)
    {
        List<FileInternalTransferIn> list = fileInternalTransferInService.selectFileInternalTransferInList(fileInternalTransferIn);
        ExcelUtil.exportExcel(list, "内部转入", FileInternalTransferIn.class, response);
//        ExcelUtil<FileInternalTransferIn> util = new ExcelUtil<FileInternalTransferIn>(FileInternalTransferIn.class);
//        return util.exportExcel(list, "in");
    }

    /**
     * 获取内部转入详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:in:query')")
    @GetMapping(value = "/{id}")
    public R<FileInternalTransferIn> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(fileInternalTransferInService.selectFileInternalTransferInById(id));
    }

    /**
     * 新增内部转入
     */
    @PreAuthorize("@ss.hasPermi('business:in:add')")
    @Log(title = "内部转入", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody FileInternalTransferIn fileInternalTransferIn)
    {
        return toAjax(fileInternalTransferInService.insertFileInternalTransferIn(fileInternalTransferIn));
    }

    /**
     * 修改内部转入
     */
    @PreAuthorize("@ss.hasPermi('business:in:edit')")
    @Log(title = "内部转入", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody FileInternalTransferIn fileInternalTransferIn)
    {
        return toAjax(fileInternalTransferInService.updateFileInternalTransferIn(fileInternalTransferIn));
    }

    /**
     * 删除内部转入
     */
    @PreAuthorize("@ss.hasPermi('business:in:remove')")
    @Log(title = "内部转入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return toAjax(fileInternalTransferInService.deleteFileInternalTransferInByIds(ids));
    }
}
